"""_summary_

Returns:
    _type_: _description_
"""
import json
import os

from app.api.service import agv_service
from app.common.response.response_schema import response_base
from app.core.conf import ST
from app.schemas.agv import RQAGVInfo, RQAGVInfoMap
from fastapi import APIRouter

info_router = APIRouter()


@info_router.post("/all1", summary="获取AGV all1的信息")
async def get_agv1_all(params: RQAGVInfo):
    """_summary_

    Args:
        params (RQAGVInfo): _description_

    Returns:
        _type_: _description_
    """
    all1_info_path = ST.get_all1_info_path(params.m_ip)
    if os.path.exists(all1_info_path):
        with open(all1_info_path, "r", encoding="utf-8") as f:
            data = json.load(f)
        return response_base.response_200(msg="查询成功", data=data)
    else:
        return response_base.response_200(msg="查询成功", data="")


@info_router.post("/map", summary="获取地图")
async def get_map(params: RQAGVInfoMap):
    """_summary_

    Args:
        params (RQAGVInfoMap): _description_

    Returns:
        _type_: _description_
    """
    res = await agv_service.get_agv_map(params)
    return response_base.response_200(msg="执行成功", data=res)
